<?php
	require_once("../conexion/conexion.php");
	extract($_POST);
	$fac = $_POST['fac'];
	$rut = $_POST['rut'];
	$con = new Conexion();
    $con2 = $con->conexionBD("fpproduccion");
	$sql = "select 
				FCNeto,
				date_format(FCFecha,'%d-%m-%Y') as fecha,
				FCResto
				
				from faccompra
				where FCNum='".$fac."' and ProvRut='".$rut."'";
	$res = mysql_query($sql) or die ($con->error_mysql("Error en la consulta".mysql_error()));
	$res = mysql_fetch_array($res);
	$iva = round($res[0]*0.19);
	$total = ($res[0]+$iva);
	$con->cerrarBD();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin t&iacute;tulo</title>
<link href="../Estilos/global.css" rel="stylesheet" type="text/css" />
<link href="../Estilos/local.css" rel="stylesheet" type="text/css" />
<link href="../Estilos/CssTabla3.css" rel="stylesheet" type="text/css" />
<link href="../Estilos/jquery.autocomplete.css" rel="stylesheet" type="text/css" />

<script src="../include_js/jquery.js" type="text/javascript"></script>
<style>
.texto
{
	font-size:14px;
	margin-left:10px;
	font:Verdana, Arial, Helvetica, sans-serif; 
	color:#0066CC;
}
.borde
{
	/*border:0px solid #6593C0;*/
	border:1px solid #D3E4E5;
}
.asterisco
{
	color:#0000FF;
	font-weight:bold;
}
.filaPar
{
	background:#81D371; 
	font-family:Verdana, Arial, Helvetica, sans-serif; 
    font-size:11px;
	text-align:center;
	vertical-align:middle;
	padding:3px;
}
.filaImpar
{
	background:#AEF1A1;
	font-family:Verdana, Arial, Helvetica, sans-serif; 
    font-size:11px;
	text-align:center;
	vertical-align:middle;
	padding:3px;
}
</style>
</head>

<body>
<form name="form_FacNormal" id="form_FacNormal" method="post">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
    <td class="borde" colspan="2"><label class="texto" style="font-weight:bold;">Datos de la Factura <?php echo $fac;?>.</label></td>
    <td class="borde">&nbsp;</td>
    <td class="borde"><label class="texto" style="font-weight:bold;">Saldo Pendiente $<?php echo number_format($res[2],0,',','.')?>.</label><input type="hidden" name="txtResto" id="txtResto" value="<?php echo $res[2];?>" /></td>
  </tr>
  <tr>
    <td class="borde">&nbsp;</td>
    <td class="borde">&nbsp;</td>
    <td class="borde">&nbsp;</td>
    <td class="borde">&nbsp;</td>
  </tr>
  <tr>
  	<td width="17%" class="borde"><label class="texto">Fecha Factura:</label></td>
	<td width="21%" class="borde"><input type="text" name="txtFecha" readonly="true" size="10" value="<?php echo $res[1];?>" style=" background:#E1E1E1" /></td>
	<td width="14%" class="borde"><label class="texto">Valor Neto:</label></td>
	<td width="48%" class="borde"><input type="text" name="txtNeto" readonly="true" value="<?php echo number_format($res[0],0,',','.')?>" style=" background:#E1E1E1" /></td>
  </tr>
  <tr>
    <td class="borde">&nbsp;</td>
    <td class="borde">&nbsp;</td>
    <td class="borde"><label class="texto">I.V.A:</label></td>
    <td class="borde"><input type="text" name="txtIVA" value="<?php echo number_format($iva,0,',','.');?>" readonly="true" style=" background:#E1E1E1"/></td>
  </tr>
  <tr>
    <td class="borde">&nbsp;</td>
    <td class="borde">&nbsp;</td>
    <td class="borde"><label class="texto">Valor Total:</label></td>
    <td class="borde"><input type="text" name="txtPrecio" readonly="true" value="<?php echo number_format($total,0,',','.')?>" style=" background:#E1E1E1" /></td>
  </tr>
  <tr>
    <td class="borde"><label class="texto" style="font-weight:bold;">Items:</label></td>
    <td class="borde">&nbsp;</td>
    <td class="borde">&nbsp;</td>
    <td class="borde">&nbsp;</td>
  </tr>
  <tr>
    <td class="borde">&nbsp;</td>
    <td class="borde">&nbsp;</td>
    <td class="borde">&nbsp;</td>
    <td class="borde">&nbsp;</td>
  </tr>
  </table>
  <div style="margin-left:10px;">
	<table width="90%" border="0" cellpadding="0" cellspacing="0" id="TItems" class="uno">
		<thead>
		<tr>
    		<th width="12%" class="borde">cantidad</th>
    		<th width="47%" class="borde">detalle</th>
    		<th width="23%" class="borde">valor unitario($)</th>
			<th width="18%" class="borde">Total($)</th>
    	</tr>
		</thead>
		<?php
		$con = new Conexion();
		$con2 = $con->conexionBD("fpproduccion");
		$sql = "select 
					DetCant,
					DetObs,
					DetUnit,
					DetTotal
					from detallefaccom
					where FCNum='".$fac."'";
		$res = mysql_query($sql) or die ($con->error_mysql("Error en la consulta".mysql_error()));
			$cont=1;
			while($reg = mysql_fetch_array($res))
			{
				if(($cont % 2)==0)
				{
					echo "<tr class=\"filaPar\">";
					echo "<td width=\"12%\" class=\"filaPar\">".$reg['DetCant']."</td>";
					echo "<td width=\"47%\" class=\"filaPar\">".$reg['DetObs']."</td>";
					echo "<td width=\"23%\" class=\"filaPar\">$".number_format ($reg['DetUnit'],0,',','.')."</td>";
					echo "<td width=\"18%\" class=\"filaPar\">$".number_format ($reg['DetTotal'],0,',','.')."</td>";
					echo "</tr>";
				}
				else
				{
					echo "<tr class=\"filaImpar\">";
					echo "<td width=\"12%\" class=\"filaImpar\">".$reg['DetCant']."</td>";
					echo "<td width=\"47%\" class=\"filaImpar\">".$reg['DetObs']."</td>";
					echo "<td width=\"23%\" class=\"filaImpar\">$".number_format ($reg['DetUnit'],0,',','.')."</td>";
					echo "<td width=\"18%\" class=\"filaImpar\">$".number_format ($reg['DetTotal'],0,',','.')."</td>";
					echo "</tr>";
				}
				$cont++;
			}
		$con->cerrarBD();
		?>
	</table>
  </div>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
 <tr>
    <td class="borde" colspan="4">&nbsp;</td>
  </tr>
  <tr>
    <td class="borde" colspan="4"><hr /></td>
  </tr>
</table>
</form>
</body>
</html>
